
import re

# 匹配
result = re.match(r"^a[^a]*d","absdad")
print(result)

# 查找
ret = re.search(r"\d+","阅读数量 99999,点击数量 5555")
print(ret)
print(ret.group())

# 查找所有
ret = re.findall(r"\d+","python = 999 ,c = 123,java = 234")
print(ret)

# 替换
ret = re.sub(r"\d+","998","python = 997，c = 1024")
print(ret)

def add(temp):
    num = temp.group()
    return str(int(num) + 1)

# 调用函数替换
ret = re.sub(r"\d+",add,"python = 997，c = 1024")
print(ret)

# 切分
ret = re.split(r":| ","qwe:asd zxc")
print(ret)